/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2010
Version 0.1
=======================================================*/
#ifndef __SDEVICES_H__
#define __SDEVICES_H__

#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <rgcpp/tools/StringTokenizer.h>

namespace acs
{

#define SC_DEVICE_LOG_LIMIT 20

#define SC_ACTION_NEW "new"
#define SC_ACTION_SHOW "show"
#define SC_ACTION_EDIT "edit"
#define SC_ACTION_CONSOLE "console"

class SDevices
{
	public:
		static std::vector<std::string> getHtml(std::string divID, std::string query);

		static std::vector<std::string> createDevice(std::string name, std::string license, int configID, std::string description);
		static std::vector<std::string> saveDevice(int deviceID, std::string name, std::string license, int configID, std::string description);
		static std::vector<std::string> validateDevice(int deviceID);
		static std::vector<std::string> removeDevice(int deviceID);

		static std::vector<std::string> clearDeviceBackupRestoreFile(std::string divID, int deviceID);

		static std::vector<std::string> addDeviceCommand(std::string divID, int id, std::string command);
		static std::vector<std::string> switchDeviceCommand(std::string divID, int id, int index1, int index2);
		static std::vector<std::string> removeDeviceCommand(std::string divID, int id, int index);

		static std::vector<std::string> generateConfiguration(int deviceID, std::string name);

		static std::vector<std::string> getDevices(std::string query);
		static std::vector<std::string> getLogs(int deviceID, int offset, int limit);

	private:
		static std::vector<std::string> getDeviceListHtml(std::string divID, std::string text);
		static std::vector<std::string> getNewDeviceHtml(std::string divID);
		static std::vector<std::string> getEditDeviceHtml(std::string divID, int deviceID);
		static std::vector<std::string> getConsoleDeviceHtml(std::string divID, int deviceID);
		static std::vector<std::string> getDeviceHtml(std::string divID, int deviceID);

		static std::string getDeviceCommandHtml(int deviceID);

		static std::string getDevicesHtml(std::string text);
		static std::string getLogsHtml(int deviceID, int offset, int limit);
};

}

#endif

